// bankMachineSim
// This is the entrance to our program
// This shows a JFrame that allows you to login to the bank account
// jar -cvf atm.jar *.class *.jpg *.png *.txt
// jar -ufe atm.jar bankMachineSim bankMachineSim.class

// usual importing of necessary class packages
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
//Necessary packages for database
import java.io.*;
import java.util.Scanner;
import java.lang.*;

import java.awt.Font; 
import javax.swing.plaf.FontUIResource;

public class bankMachineSim extends JFrame //Inherits JFrame class
{
	//Declares objects from predefined classes
	String strReadClientInfo[];
	String strReadCheckingBalance[];
	String strReadSavingsBalance[];
	JTextField accountNumber;
	JTextField depositAmount; // checking acc
	JTextField depositAmount2; // savings acc
	JTextField tranferAmount; // checking acc
	JTextField tranferAmount2; // savings acc
	double depositValue;
	double tranferValue; // checking acc
	double tranferValue2; // savings acc
	JPasswordField pinNumber;
	JButton logInButton;
	double checkingBalance;
	double savingsBalance;
	double roundOff;
	
	//Declaration of database objects checking acc
   	File clientInfoCheckingBal;
   	FileWriter clientInfoDataFW;
	BufferedWriter clientInfoDataBW;
	
	//Declaration of database objects savings acc
   	File clientInfoSavingsBal;
   	//FileWriter clientInfoDataFW;
	//BufferedWriter clientInfoDataBW;
	
    public bankMachineSim() 
    {
    	super ("Welcome to Virtual Bank");//Adds a title
    	
    	UIManager.put("OptionPane.buttonFont", new FontUIResource(new Font("ARIAL",Font.BOLD,45)));
		UIManager.put("OptionPane.messageFont", new FontUIResource(new Font("ARIAL",Font.BOLD,30)));
	    
	    getContentPane().setLayout(new FlowLayout());//Sets layout
	    getContentPane().setBackground( Color.gray );//Sets background
      	
      	
		///////////////////////////////////////////////////////////////////////////////////////////////////////Acc and PIN
		//Reads client's information and assigns each line to a string value 
    	strReadClientInfo = new String[2];
		try 
       	{
        	BufferedReader readClientInfo = new BufferedReader (new FileReader(new File("clientInfoDataBase.txt")));
        					
        	//Reads each line
        	for (int i = 0; i<strReadClientInfo.length; i++)
        	{
        		strReadClientInfo[i] = readClientInfo.readLine();
        		
        	}
        					
	
        					
        	//A test dialog to indicate success
        	//JOptionPane.showMessageDialog (bankMachineSim.this, "Successful at reading client database.");
        	readClientInfo.close();//Closes reader
        }
        				  				
        				
        //Throws exceptions
       	catch (FileNotFoundException fnfe) 
    	{
			JOptionPane.showMessageDialog (bankMachineSim.this, "Cannot find file. Error: "+fnfe.getMessage());
		} 
			catch (IOException ioe) 
		{
			JOptionPane.showMessageDialog (bankMachineSim.this, "Problem reading file. Error: "+ioe.getMessage());
    	}


		///////////////////////////////////////////////////////////////////////////////////////////////////////Checking acc
     	//Reads client's information and assigns each line to a string value 
    	strReadCheckingBalance = new String[2];
		try 
       	{
        	BufferedReader readCheckingBalance = new BufferedReader (new FileReader(new File("clientInfoCheckingBalance.txt")));
        	
			for (int i = 0; i<strReadCheckingBalance.length; i++)
        	{			
				strReadCheckingBalance[i] = readCheckingBalance.readLine();
        	}				
	
        					
        	//A test dialog to indicate success
        	//JOptionPane.showMessageDialog (bankMachineSim.this, "Successful at reading client database.");
        	readCheckingBalance.close();//Closes reader
        }
        				  				
        				
        //Throws exceptions
       	catch (FileNotFoundException fnfe) 
    	{
			JOptionPane.showMessageDialog (bankMachineSim.this, "Cannot find file. Error: "+fnfe.getMessage());
		} 
			catch (IOException ioe) 
		{
			JOptionPane.showMessageDialog (bankMachineSim.this, "Problem reading file. Error: "+ioe.getMessage());
    	}
      	
		///////////////////////////////////////////////////////////////////////////////////////////////////////Savings acc
		//Reads client's information and assigns each line to a string value 
    	strReadSavingsBalance = new String[2];
		try 
       	{
        	BufferedReader readSavingsBalance = new BufferedReader (new FileReader(new File("clientInfoSavingsBalance.txt")));
        	
			for (int i = 0; i<strReadSavingsBalance.length; i++)
        	{			
				strReadSavingsBalance[i] = readSavingsBalance.readLine();
        	}				
	
        					
        	//A test dialog to indicate success
        	//JOptionPane.showMessageDialog (bankMachineSim.this, "Successful at reading client database.");
        	readSavingsBalance.close();//Closes reader
        }
        				  				
        				
        //Throws exceptions
       	catch (FileNotFoundException fnfe) 
    	{
			JOptionPane.showMessageDialog (bankMachineSim.this, "Cannot find file. Error: "+fnfe.getMessage());
		} 
			catch (IOException ioe) 
		{
			JOptionPane.showMessageDialog (bankMachineSim.this, "Problem reading file. Error: "+ioe.getMessage());
    	}
      	
      	//Creates an image
      	Icon logoCompany = new ImageIcon( "gradient_test.jpg" );
      	JLabel logoPicture = new JLabel(logoCompany);
      	getContentPane().add( logoPicture );//Adds to container
    	
		//Instantiates and sets properties to panels
    	JPanel panelStart = new JPanel(new GridLayout (0,1));
    	panelStart.setPreferredSize(new Dimension(400, 90));
    	panelStart.setBorder(BorderFactory.createLineBorder( Color.orange.darker() ));
    	panelStart.setBackground( Color.gray );
    	getContentPane().add( panelStart );
		JButton startButton = new JButton ("Tap here to start");
		startButton.setFont(new Font("Arial", Font.BOLD, 40));
		panelStart.add (startButton);
		
		
		//****************************************************Account display
    	JPanel accDisplay = new JPanel(new GridLayout (0,1));
    	accDisplay.setPreferredSize(new Dimension(700, 200));
    	//accDisplay.setBorder(BorderFactory.createLineBorder( Color.orange.darker() ));
    	accDisplay.setBackground( Color.gray );
		accDisplay.add(new Label(""));
		JLabel accountDisplay = new JLabel("Please Enter Account Number (7 digits): ");
		accountDisplay.setFont(new Font("Arial", Font.BOLD, 30));
      	accDisplay.add( accountDisplay );
		
		accountNumber = new JTextField (16);
		accountNumber.setFont(new Font("Arial", Font.BOLD, 30));
		accountNumber.setEditable(false);
 		accDisplay.add (accountNumber);
		accDisplay.add(new Label(""));
		
		//****************************************************card display
    	JPanel cardDisplay = new JPanel(new FlowLayout ());
    	cardDisplay.setPreferredSize(new Dimension(890, 325));
    	//cardDisplay.setBorder(BorderFactory.createLineBorder( Color.orange.darker() ));
    	cardDisplay.setBackground( Color.gray );
		JLabel wwDisplay = new JLabel("<html>Typing Account Number and tapping ENTER key <br>above simulates a successful card insertion swipe</html>");
		wwDisplay.setFont(new Font("Arial", Font.BOLD, 24));
		cardDisplay.add( wwDisplay );
		//Creates an image
      	Icon cardpic = new ImageIcon( "magswipe.PNG" );
      	JLabel cardpicture = new JLabel(cardpic);
      	cardDisplay.add( cardpicture );//Adds to container
		
		//****************************************************Account num pad
		JButton[] accNumButtons = new JButton[10];
		for (int i = 0; i < accNumButtons.length; i++) {
			accNumButtons[i] = new JButton("" + i);
		}
		//number pad
		JPanel accNumPad = new JPanel();
		accNumPad.setLayout(new GridLayout(4, 3));
		accNumPad.setPreferredSize(new Dimension(400, 400));
		for (int i = 1; i <= 9; i++) {
			accNumButtons[i].setFont(new Font("Arial", Font.BOLD, 40));
			accNumPad.add(accNumButtons[i]);
		}
		accNumPad.add(new Label(""));
		//JButton aDot = new JButton(".");
		//aDot.setFont(new Font("Arial", Font.BOLD, 40));
		accNumButtons[0].setFont(new Font("Arial", Font.BOLD, 40));
		accNumPad.add(accNumButtons[0]);
		//accNumPad.add(aDot);
		accNumPad.add(new Label(""));
		//****************************************************
		
		//****************************************************Account edit keys
    	JPanel accEditKeys = new JPanel(new GridLayout (0,1));
    	accEditKeys.setPreferredSize(new Dimension(250, 400));
    	//accEditKeys.setBorder(BorderFactory.createLineBorder( Color.orange.darker() ));
    	accEditKeys.setBackground( Color.gray );
		JButton accCancelKey = new JButton("CANCEL");
		accCancelKey.setBackground( Color.red );
		accCancelKey.setFont(new Font("Arial", Font.BOLD, 40));
		JButton accClearKey = new JButton("CLEAR");
		accClearKey.setBackground( Color.yellow );
		accClearKey.setFont(new Font("Arial", Font.BOLD, 40));
		JButton accEnterKey = new JButton("ENTER");
		accEnterKey.setBackground( Color.green );
		accEnterKey.setFont(new Font("Arial", Font.BOLD, 40));
		accEditKeys.add(accCancelKey);
		accEditKeys.add(accClearKey);
		accEditKeys.add(accEnterKey);
		accEditKeys.add(new Label(""));
		 		
 		startButton.addActionListener(new ActionListener()
        		{
        			//Actions when login button is clicked
        			public void actionPerformed(ActionEvent e)
        			{         
						panelStart.setVisible(false);
						logoPicture.setVisible(false);
						getContentPane().add( accDisplay );
						getContentPane().add( accNumPad );
						getContentPane().add( accEditKeys );
						getContentPane().add( cardDisplay );
        			}
        		}
        	
        	);		
 			
 		//****************************************************AccNum action listen
		accNumButtons[0].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ accountNumber.setText(accountNumber.getText() + accNumButtons[0].getText()); }});
		accNumButtons[1].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ accountNumber.setText(accountNumber.getText() + accNumButtons[1].getText()); }});
		accNumButtons[2].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ accountNumber.setText(accountNumber.getText() + accNumButtons[2].getText()); }});
		accNumButtons[3].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ accountNumber.setText(accountNumber.getText() + accNumButtons[3].getText()); }});
		accNumButtons[4].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ accountNumber.setText(accountNumber.getText() + accNumButtons[4].getText()); }});
		accNumButtons[5].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ accountNumber.setText(accountNumber.getText() + accNumButtons[5].getText()); }});
		accNumButtons[6].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ accountNumber.setText(accountNumber.getText() + accNumButtons[6].getText()); }});
		accNumButtons[7].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ accountNumber.setText(accountNumber.getText() + accNumButtons[7].getText()); }});
		accNumButtons[8].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ accountNumber.setText(accountNumber.getText() + accNumButtons[8].getText()); }});
		accNumButtons[9].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ accountNumber.setText(accountNumber.getText() + accNumButtons[9].getText()); }});					
		
		accClearKey.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ accountNumber.setText(""); }});
		
		accCancelKey.addActionListener(new ActionListener()
				{
					//Actions when login button is clicked
					public void actionPerformed(ActionEvent e)
					{         
						JOptionPane.showMessageDialog (bankMachineSim.this, "Exiting session. Please restart Bank Machine Simulation for new session.");
						System.exit( 0 );//Closes window
					}
				}
			
			);
		
		//****************************************************Pin display
    	JPanel pinDisplay = new JPanel(new GridLayout (0,1));
    	pinDisplay.setPreferredSize(new Dimension(700, 200));
    	//pinDisplay.setBorder(BorderFactory.createLineBorder( Color.orange.darker() ));
    	pinDisplay.setBackground( Color.gray );
		pinDisplay.add(new Label(""));
				
		JLabel pinnDisplay = new JLabel("Please Enter PIN number (4 digits)");
		pinnDisplay.setFont(new Font("Arial", Font.BOLD, 30));
      	pinDisplay.add( pinnDisplay );
    	                
    	pinNumber = new JPasswordField (4);
		pinNumber.setFont(new Font("Arial", Font.BOLD, 30));
		pinNumber.setEditable(false);
 		pinDisplay.add (pinNumber); 
		pinDisplay.add(new Label(""));
		
		//****************************************************PIN num pad
		JButton[] pinNumButtons = new JButton[10];
		for (int i = 0; i < pinNumButtons.length; i++) {
			pinNumButtons[i] = new JButton("" + i);
		}
		//number pad
		JPanel pinNumPad = new JPanel();
		pinNumPad.setLayout(new GridLayout(4, 3));
		pinNumPad.setPreferredSize(new Dimension(400, 400));
		for (int i = 1; i <= 9; i++) {
			pinNumButtons[i].setFont(new Font("Arial", Font.BOLD, 40));
			pinNumPad.add(pinNumButtons[i]);
		}
		pinNumPad.add(new Label(""));
		//JButton aDot = new JButton(".");
		//aDot.setFont(new Font("Arial", Font.BOLD, 40));
		pinNumButtons[0].setFont(new Font("Arial", Font.BOLD, 40));
		pinNumPad.add(pinNumButtons[0]);
		//pinNumPad.add(aDot);
		pinNumPad.add(new Label(""));
		//****************************************************
		
		//****************************************************pin edit keys
    	JPanel pinEditKeys = new JPanel(new GridLayout (0,1));
    	pinEditKeys.setPreferredSize(new Dimension(250, 400));
    	//pinEditKeys.setBorder(BorderFactory.createLineBorder( Color.orange.darker() ));
    	pinEditKeys.setBackground( Color.gray );
		JButton pinCancelKey = new JButton("CANCEL");
		pinCancelKey.setBackground( Color.red );
		pinCancelKey.setFont(new Font("Arial", Font.BOLD, 40));
		JButton pinClearKey = new JButton("CLEAR");
		pinClearKey.setBackground( Color.yellow );
		pinClearKey.setFont(new Font("Arial", Font.BOLD, 40));
		JButton pinEnterKey = new JButton("ENTER");
		pinEnterKey.setBackground( Color.green );
		pinEnterKey.setFont(new Font("Arial", Font.BOLD, 40));
		pinEditKeys.add(pinCancelKey);
		pinEditKeys.add(pinClearKey);
		pinEditKeys.add(pinEnterKey);
		pinEditKeys.add(new Label(""));
		
		
		accEnterKey.addActionListener(new ActionListener()
        		{
        			//Actions when login button is clicked
        			public void actionPerformed(ActionEvent e)
        			{
		
						//If theres no input for either fields the following would be executed
                		if  (accountNumber.getText() == null || (accountNumber.getText()).equals(""))
                		{
                    		//Message dialog would be displayed if at least a required field is not filled
                			JOptionPane.showMessageDialog(bankMachineSim.this,
                    			"Please fill out the required fields.");
                		}               
                
                		//If the login and password is filled out then log in is successful
                		else if ((accountNumber.getText()).equals(strReadClientInfo[0]))
                		{
              
                	
                			JOptionPane.showMessageDialog(bankMachineSim.this,
                   	 			"You have successfully input a valid account number. ");
								accDisplay.setVisible(false);
								cardDisplay.setVisible(false);
								accNumPad.setVisible(false);
								accEditKeys.setVisible(false);
								getContentPane().add( pinDisplay );
								getContentPane().add( pinNumPad );
								getContentPane().add( pinEditKeys );
                   	
                	   }
                	   
                	   //If password and username is invalid
                	   else
                	   {
                	   		JOptionPane.showMessageDialog (bankMachineSim.this, "Invalid input");
                	   }
                

		
        			}
        		}
        	
        	);
		
		//****************************************************pin action listen
		pinNumButtons[0].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ pinNumber.setText(pinNumber.getText() + pinNumButtons[0].getText()); }});
		pinNumButtons[1].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ pinNumber.setText(pinNumber.getText() + pinNumButtons[1].getText()); }});
		pinNumButtons[2].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ pinNumber.setText(pinNumber.getText() + pinNumButtons[2].getText()); }});
		pinNumButtons[3].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ pinNumber.setText(pinNumber.getText() + pinNumButtons[3].getText()); }});
		pinNumButtons[4].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ pinNumber.setText(pinNumber.getText() + pinNumButtons[4].getText()); }});
		pinNumButtons[5].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ pinNumber.setText(pinNumber.getText() + pinNumButtons[5].getText()); }});
		pinNumButtons[6].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ pinNumber.setText(pinNumber.getText() + pinNumButtons[6].getText()); }});
		pinNumButtons[7].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ pinNumber.setText(pinNumber.getText() + pinNumButtons[7].getText()); }});
		pinNumButtons[8].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ pinNumber.setText(pinNumber.getText() + pinNumButtons[8].getText()); }});
		pinNumButtons[9].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ pinNumber.setText(pinNumber.getText() + pinNumButtons[9].getText()); }});					
		
		pinClearKey.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ pinNumber.setText(""); }});
		
		pinCancelKey.addActionListener(new ActionListener()
				{
					//Actions when login button is clicked
					public void actionPerformed(ActionEvent e)
					{         
						JOptionPane.showMessageDialog (bankMachineSim.this, "Exiting session. Please restart Bank Machine Simulation for new session.");
						System.exit( 0 );//Closes window
					}
				}
			
			);
		
		
		//****************************************************Select action display
    	JPanel actionDisplay = new JPanel(new GridLayout (0,1));
    	actionDisplay.setPreferredSize(new Dimension(700, 820));
    	//actionDisplay.setBorder(BorderFactory.createLineBorder( Color.orange.darker() ));
    	actionDisplay.setBackground( Color.gray );
		actionDisplay.add(new Label(""));
				
		JLabel actDisplay = new JLabel("Please Select a Task Below:");
		actDisplay.setFont(new Font("Arial", Font.BOLD, 24));
      	actionDisplay.add( actDisplay );
		actionDisplay.add(new Label(""));
    	JButton withdrawKey = new JButton("Withdraw");
		withdrawKey.setFont(new Font("Arial", Font.BOLD, 40));
		JButton depositKey = new JButton("Deposit");
		depositKey.setFont(new Font("Arial", Font.BOLD, 40));
		JButton transferKey = new JButton("Transfer");
		transferKey.setFont(new Font("Arial", Font.BOLD, 40));
		JButton balanceKey = new JButton("Display Account Balances");
		balanceKey.setFont(new Font("Arial", Font.BOLD, 40));
		actionDisplay.add(withdrawKey);
		actionDisplay.add(new Label(""));
		actionDisplay.add(depositKey);
		actionDisplay.add(new Label(""));
		actionDisplay.add(transferKey);
		actionDisplay.add(new Label(""));
		actionDisplay.add(balanceKey);                
    	
		//actionDisplay.add(new Label(""));
		
		pinEnterKey.addActionListener(new ActionListener()
        		{
        			//Actions when login button is clicked
        			public void actionPerformed(ActionEvent e)
        			{
		
						//If theres no input for either fields the following would be executed
                		if  ( pinNumber.getPassword() == null || (pinNumber.getPassword()).length == 0 )
                		{
                    		//Message dialog would be displayed if at least a required field is not filled
                			JOptionPane.showMessageDialog(bankMachineSim.this,
                    			"Please fill out the required fields.");
                		}               
                
                		//If the login and password is filled out then log in is successful
                		else if (isPasswordCorrect(pinNumber.getPassword()))
                		{
              
                	
                			JOptionPane.showMessageDialog(bankMachineSim.this,
                   	 			"You have successfully logged in to your account. ");
								pinDisplay.setVisible(false);
								pinNumPad.setVisible(false);
								pinEditKeys.setVisible(false);
								getContentPane().add( actionDisplay );
								//getContentPane().add( pinNumPad );
								//getContentPane().add( pinEditKeys );
                   	
                	   }
                	   
                	   //If password and username is invalid
                	   else
                	   {
                	   		JOptionPane.showMessageDialog (bankMachineSim.this, "Invalid input");
                	   }
                

		
        			}
        		}
        	
        	);
        
		balanceKey.addActionListener(new ActionListener()
				{
					//Actions when login button is clicked
					public void actionPerformed(ActionEvent e)
					{         
						JOptionPane.showMessageDialog (bankMachineSim.this, "The following are the current balances of your accounts: \n \n Checking Account Balance: $"+strReadCheckingBalance[0]+" \n Savings Account Balance: $"+strReadSavingsBalance[0]);
					}
				}
			
			);
			
		//****************************************************Withdraw display
    	JPanel withdrawDisplay = new JPanel(new GridLayout (0,1));
    	withdrawDisplay.setPreferredSize(new Dimension(750, 800));
    	//withdrawDisplay.setBorder(BorderFactory.createLineBorder( Color.orange.darker() ));
    	withdrawDisplay.setBackground( Color.gray );
		withdrawDisplay.add(new Label(""));
				
		JLabel actDisplay1 = new JLabel("Please Select an Account to Withdraw Money from:");
		actDisplay1.setFont(new Font("Arial", Font.BOLD, 24));
      	withdrawDisplay.add( actDisplay1 );
		withdrawDisplay.add(new Label(""));
    	JButton withdrawCheckingKey = new JButton("Checking Account");
		withdrawCheckingKey.setFont(new Font("Arial", Font.BOLD, 40));
		JButton withdrawSavingsKey = new JButton("Savings Account");
		withdrawSavingsKey.setFont(new Font("Arial", Font.BOLD, 40));
		
		withdrawDisplay.add(withdrawCheckingKey);
		withdrawDisplay.add(new Label(""));
		withdrawDisplay.add(withdrawSavingsKey);
		withdrawDisplay.add(new Label(""));


		
		withdrawKey.addActionListener(new ActionListener()
				{
					//Actions when login button is clicked
					public void actionPerformed(ActionEvent e)
					{         
						actionDisplay.setVisible(false);
						getContentPane().add( withdrawDisplay );

					}
				}
			
			);
		
		//****************************************************Deposit display
    	JPanel depositDisplay = new JPanel(new GridLayout (0,1));
    	depositDisplay.setPreferredSize(new Dimension(750, 800));
    	//depositDisplay.setBorder(BorderFactory.createLineBorder( Color.orange.darker() ));
    	depositDisplay.setBackground( Color.gray );
		depositDisplay.add(new Label(""));
				
		JLabel actDisplay2 = new JLabel("Please Select an Account to Deposit Money to:");
		actDisplay2.setFont(new Font("Arial", Font.BOLD, 24));
      	depositDisplay.add( actDisplay2 );
		depositDisplay.add(new Label(""));
    	JButton depositCheckingKey = new JButton("Checking Account");
		depositCheckingKey.setFont(new Font("Arial", Font.BOLD, 40));
		JButton depositSavingsKey = new JButton("Savings Account");
		depositSavingsKey.setFont(new Font("Arial", Font.BOLD, 40));
		
		depositDisplay.add(depositCheckingKey);
		depositDisplay.add(new Label(""));
		depositDisplay.add(depositSavingsKey);
		depositDisplay.add(new Label(""));
		
		depositKey.addActionListener(new ActionListener()
				{
					//Actions when login button is clicked
					public void actionPerformed(ActionEvent e)
					{         
						actionDisplay.setVisible(false);
						getContentPane().add( depositDisplay );

					}
				}
			
			);
		
		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Withdraw section
		//****************************************************Withdraw from checking display
    	
		//****************************************************title display
    	JPanel titleDisplay = new JPanel(new GridLayout (0,1));
    	titleDisplay.setPreferredSize(new Dimension(880, 200));
    	//titleDisplay.setBorder(BorderFactory.createLineBorder( Color.orange.darker() ));
    	titleDisplay.setBackground( Color.gray );
		JLabel wwwDisplay = new JLabel("<html>Withdraw cash from Checking Account <br>Please select amount below (max $160):</html>");
		wwwDisplay.setFont(new Font("Arial", Font.BOLD, 24));
		titleDisplay.add( wwwDisplay );
		
		JPanel withdrawCheckingDisplay = new JPanel(new GridLayout (0,2));
    	withdrawCheckingDisplay.setPreferredSize(new Dimension(700, 600));
    	//withdrawCheckingDisplay.setBorder(BorderFactory.createLineBorder( Color.orange.darker() ));
    	withdrawCheckingDisplay.setBackground( Color.gray );
		//withdrawCheckingDisplay.add(new Label(""));
		
    	JButton the20Key = new JButton("$ 20");
		the20Key.setFont(new Font("Arial", Font.BOLD, 40));
		JButton the40Key = new JButton("$ 40");
		the40Key.setFont(new Font("Arial", Font.BOLD, 40));
		JButton the60Key = new JButton("$ 60");
		the60Key.setFont(new Font("Arial", Font.BOLD, 40));
		JButton the80Key = new JButton("$ 80");
		the80Key.setFont(new Font("Arial", Font.BOLD, 40));
    	JButton the100Key = new JButton("$ 100");
		the100Key.setFont(new Font("Arial", Font.BOLD, 40));
		JButton the120Key = new JButton("$ 120");
		the120Key.setFont(new Font("Arial", Font.BOLD, 40));
		JButton the140Key = new JButton("$ 140");
		the140Key.setFont(new Font("Arial", Font.BOLD, 40));
		JButton the160Key = new JButton("$ 160");
		the160Key.setFont(new Font("Arial", Font.BOLD, 40));
		withdrawCheckingDisplay.add(the20Key);
		withdrawCheckingDisplay.add(the40Key);
		withdrawCheckingDisplay.add(the60Key);
		withdrawCheckingDisplay.add(the80Key);
		withdrawCheckingDisplay.add(the100Key);
		withdrawCheckingDisplay.add(the120Key);
		withdrawCheckingDisplay.add(the140Key);
		withdrawCheckingDisplay.add(the160Key);
		
		withdrawCheckingKey.addActionListener(new ActionListener()
				{
					//Actions when login button is clicked
					public void actionPerformed(ActionEvent e)
					{         
						withdrawDisplay.setVisible(false);
						getContentPane().add( titleDisplay );
						getContentPane().add( withdrawCheckingDisplay );

					}
				}
			
			);
		
		//****************************************************Withdraw from Savings display
    	//****************************************************title display
    	JPanel titleDisplay2 = new JPanel(new GridLayout (0,1));
    	titleDisplay2.setPreferredSize(new Dimension(880, 200));
    	//titleDisplay2.setBorder(BorderFactory.createLineBorder( Color.orange.darker() ));
    	titleDisplay2.setBackground( Color.gray );
		JLabel wwwDisplay2 = new JLabel("<html>Withdraw cash from Savings Account <br>Please select amount below (max $160):</html>");
		wwwDisplay2.setFont(new Font("Arial", Font.BOLD, 24));
		titleDisplay2.add( wwwDisplay2 );
		
		JPanel withdrawSavingsDisplay = new JPanel(new GridLayout (0,2));
    	withdrawSavingsDisplay.setPreferredSize(new Dimension(700, 600));
    	//withdrawSavingsDisplay.setBorder(BorderFactory.createLineBorder( Color.orange.darker() ));
    	withdrawSavingsDisplay.setBackground( Color.gray );
		//withdrawSavingsDisplay.add(new Label(""));
		
    	JButton the20Key2 = new JButton("$ 20");
		the20Key2.setFont(new Font("Arial", Font.BOLD, 40));
		JButton the40Key2 = new JButton("$ 40");
		the40Key2.setFont(new Font("Arial", Font.BOLD, 40));
		JButton the60Key2 = new JButton("$ 60");
		the60Key2.setFont(new Font("Arial", Font.BOLD, 40));
		JButton the80Key2 = new JButton("$ 80");
		the80Key2.setFont(new Font("Arial", Font.BOLD, 40));
    	JButton the100Key2 = new JButton("$ 100");
		the100Key2.setFont(new Font("Arial", Font.BOLD, 40));
		JButton the120Key2 = new JButton("$ 120");
		the120Key2.setFont(new Font("Arial", Font.BOLD, 40));
		JButton the140Key2 = new JButton("$ 140");
		the140Key2.setFont(new Font("Arial", Font.BOLD, 40));
		JButton the160Key2 = new JButton("$ 160");
		the160Key2.setFont(new Font("Arial", Font.BOLD, 40));
		withdrawSavingsDisplay.add(the20Key2);
		withdrawSavingsDisplay.add(the40Key2);
		withdrawSavingsDisplay.add(the60Key2);
		withdrawSavingsDisplay.add(the80Key2);
		withdrawSavingsDisplay.add(the100Key2);
		withdrawSavingsDisplay.add(the120Key2);
		withdrawSavingsDisplay.add(the140Key2);
		withdrawSavingsDisplay.add(the160Key2);
		
		withdrawSavingsKey.addActionListener(new ActionListener()
				{
					//Actions when login button is clicked
					public void actionPerformed(ActionEvent e)
					{         
						withdrawDisplay.setVisible(false);
						getContentPane().add( titleDisplay2 );
						getContentPane().add( withdrawSavingsDisplay );

					}
				}
			
			);
		
		//****************************************************Withdraw Cash confirm display -CHECKING ACC
    	JPanel cashConfirmDisplay = new JPanel(new GridLayout (0,1));
    	cashConfirmDisplay.setPreferredSize(new Dimension(880, 620));
    	//cashConfirmDisplay.setBorder(BorderFactory.createLineBorder( Color.orange.darker() ));
    	cashConfirmDisplay.setBackground( Color.gray );
		//cashConfirmDisplay.add(new Label(""));
				
		JLabel cashConfDisplay = new JLabel("Please tap below to simulate cash being removed: ");
		cashConfDisplay.setFont(new Font("Arial", Font.BOLD, 24));
      	cashConfirmDisplay.add( cashConfDisplay );
    	                
    	//Creates an image
      	Icon grabCashpic = new ImageIcon( "cashpic.PNG" );
      	JButton cashpicture = new JButton(grabCashpic);
      	cashConfirmDisplay.add( cashpicture );//Adds to container
		
		//****************************************************Withdraw Cash action listeners -CHECKING ACC
		the20Key.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ 
					checkingBalance = Double.parseDouble(strReadCheckingBalance[0]);
					checkingBalance = checkingBalance - 20;
					strReadCheckingBalance[0] = String.valueOf(checkingBalance);
					clientInfoCheckingBal = new File ("clientInfoCheckingBalance.txt"); 
					try
						{clientInfoDataFW = new FileWriter (clientInfoCheckingBal);
						clientInfoDataBW = new BufferedWriter (clientInfoDataFW);
						//clientInfoDataBW.newLine();
						//clientInfoDataBW.write(createdUsername.getText());
						clientInfoDataBW.write(strReadCheckingBalance[0]);
						clientInfoDataBW.newLine();
						clientInfoDataBW.close();}
					catch (IOException ioe) 
						{
						JOptionPane.showMessageDialog(bankMachineSim.this,
													"Problem Writing to file. "+
													"IOException: " + ioe.getMessage());
						}
					JOptionPane.showMessageDialog (bankMachineSim.this, "New Balance: $"+strReadCheckingBalance[0]); withdrawCheckingDisplay.setVisible(false); titleDisplay.setVisible(false); getContentPane().add( cashConfirmDisplay );}});
		the40Key.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ 
					checkingBalance = Double.parseDouble(strReadCheckingBalance[0]);
					checkingBalance = checkingBalance - 40;
					strReadCheckingBalance[0] = String.valueOf(checkingBalance);
					clientInfoCheckingBal = new File ("clientInfoCheckingBalance.txt"); 
					try
						{clientInfoDataFW = new FileWriter (clientInfoCheckingBal);
						clientInfoDataBW = new BufferedWriter (clientInfoDataFW);
						//clientInfoDataBW.newLine();
						//clientInfoDataBW.write(createdUsername.getText());
						clientInfoDataBW.write(strReadCheckingBalance[0]);
						clientInfoDataBW.newLine();
						clientInfoDataBW.close();}
					catch (IOException ioe) 
						{
						JOptionPane.showMessageDialog(bankMachineSim.this,
													"Problem Writing to file. "+
													"IOException: " + ioe.getMessage());
						} 
					JOptionPane.showMessageDialog (bankMachineSim.this, "New Balance: $"+strReadCheckingBalance[0]); withdrawCheckingDisplay.setVisible(false); titleDisplay.setVisible(false); getContentPane().add( cashConfirmDisplay );}});
		the60Key.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ 
					checkingBalance = Double.parseDouble(strReadCheckingBalance[0]);
					checkingBalance = checkingBalance - 60;
					strReadCheckingBalance[0] = String.valueOf(checkingBalance);
					clientInfoCheckingBal = new File ("clientInfoCheckingBalance.txt"); 
					try
						{clientInfoDataFW = new FileWriter (clientInfoCheckingBal);
						clientInfoDataBW = new BufferedWriter (clientInfoDataFW);
						//clientInfoDataBW.newLine();
						//clientInfoDataBW.write(createdUsername.getText());
						clientInfoDataBW.write(strReadCheckingBalance[0]);
						clientInfoDataBW.newLine();
						clientInfoDataBW.close();}
					catch (IOException ioe) 
						{
						JOptionPane.showMessageDialog(bankMachineSim.this,
													"Problem Writing to file. "+
													"IOException: " + ioe.getMessage());
						} 
					JOptionPane.showMessageDialog (bankMachineSim.this, "New Balance: $"+strReadCheckingBalance[0]); withdrawCheckingDisplay.setVisible(false); titleDisplay.setVisible(false); getContentPane().add( cashConfirmDisplay );}});
		the80Key.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ 
					checkingBalance = Double.parseDouble(strReadCheckingBalance[0]);
					checkingBalance = checkingBalance - 80;
					strReadCheckingBalance[0] = String.valueOf(checkingBalance);
					clientInfoCheckingBal = new File ("clientInfoCheckingBalance.txt"); 
					try
						{clientInfoDataFW = new FileWriter (clientInfoCheckingBal);
						clientInfoDataBW = new BufferedWriter (clientInfoDataFW);
						//clientInfoDataBW.newLine();
						//clientInfoDataBW.write(createdUsername.getText());
						clientInfoDataBW.write(strReadCheckingBalance[0]);
						clientInfoDataBW.newLine();
						clientInfoDataBW.close();}
					catch (IOException ioe) 
						{
						JOptionPane.showMessageDialog(bankMachineSim.this,
													"Problem Writing to file. "+
													"IOException: " + ioe.getMessage());
						}
					JOptionPane.showMessageDialog (bankMachineSim.this, "New Balance: $"+strReadCheckingBalance[0]); withdrawCheckingDisplay.setVisible(false); titleDisplay.setVisible(false); getContentPane().add( cashConfirmDisplay );}});
		the100Key.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ 
					checkingBalance = Double.parseDouble(strReadCheckingBalance[0]);
					checkingBalance = checkingBalance - 100;
					strReadCheckingBalance[0] = String.valueOf(checkingBalance);
					clientInfoCheckingBal = new File ("clientInfoCheckingBalance.txt"); 
					try
						{clientInfoDataFW = new FileWriter (clientInfoCheckingBal);
						clientInfoDataBW = new BufferedWriter (clientInfoDataFW);
						//clientInfoDataBW.newLine();
						//clientInfoDataBW.write(createdUsername.getText());
						clientInfoDataBW.write(strReadCheckingBalance[0]);
						clientInfoDataBW.newLine();
						clientInfoDataBW.close();}
					catch (IOException ioe) 
						{
						JOptionPane.showMessageDialog(bankMachineSim.this,
													"Problem Writing to file. "+
													"IOException: " + ioe.getMessage());
						}
					JOptionPane.showMessageDialog (bankMachineSim.this, "New Balance: $"+strReadCheckingBalance[0]); withdrawCheckingDisplay.setVisible(false); titleDisplay.setVisible(false); getContentPane().add( cashConfirmDisplay );}});
		the120Key.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ 
					checkingBalance = Double.parseDouble(strReadCheckingBalance[0]);
					checkingBalance = checkingBalance - 120;
					strReadCheckingBalance[0] = String.valueOf(checkingBalance);
					clientInfoCheckingBal = new File ("clientInfoCheckingBalance.txt"); 
					try
						{clientInfoDataFW = new FileWriter (clientInfoCheckingBal);
						clientInfoDataBW = new BufferedWriter (clientInfoDataFW);
						//clientInfoDataBW.newLine();
						//clientInfoDataBW.write(createdUsername.getText());
						clientInfoDataBW.write(strReadCheckingBalance[0]);
						clientInfoDataBW.newLine();
						clientInfoDataBW.close();}
					catch (IOException ioe) 
						{
						JOptionPane.showMessageDialog(bankMachineSim.this,
													"Problem Writing to file. "+
													"IOException: " + ioe.getMessage());
						}
					JOptionPane.showMessageDialog (bankMachineSim.this, "New Balance: $"+strReadCheckingBalance[0]); withdrawCheckingDisplay.setVisible(false); titleDisplay.setVisible(false); getContentPane().add( cashConfirmDisplay );}});
		the140Key.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ 
					checkingBalance = Double.parseDouble(strReadCheckingBalance[0]);
					checkingBalance = checkingBalance - 140;
					strReadCheckingBalance[0] = String.valueOf(checkingBalance);
					clientInfoCheckingBal = new File ("clientInfoCheckingBalance.txt"); 
					try
						{clientInfoDataFW = new FileWriter (clientInfoCheckingBal);
						clientInfoDataBW = new BufferedWriter (clientInfoDataFW);
						//clientInfoDataBW.newLine();
						//clientInfoDataBW.write(createdUsername.getText());
						clientInfoDataBW.write(strReadCheckingBalance[0]);
						clientInfoDataBW.newLine();
						clientInfoDataBW.close();}
					catch (IOException ioe) 
						{
						JOptionPane.showMessageDialog(bankMachineSim.this,
													"Problem Writing to file. "+
													"IOException: " + ioe.getMessage());
						}
					JOptionPane.showMessageDialog (bankMachineSim.this, "New Balance: $"+strReadCheckingBalance[0]); withdrawCheckingDisplay.setVisible(false); titleDisplay.setVisible(false); getContentPane().add( cashConfirmDisplay );}});
		the160Key.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ 
					checkingBalance = Double.parseDouble(strReadCheckingBalance[0]);
					checkingBalance = checkingBalance - 160;
					strReadCheckingBalance[0] = String.valueOf(checkingBalance);
					clientInfoCheckingBal = new File ("clientInfoCheckingBalance.txt"); 
					try
						{clientInfoDataFW = new FileWriter (clientInfoCheckingBal);
						clientInfoDataBW = new BufferedWriter (clientInfoDataFW);
						//clientInfoDataBW.newLine();
						//clientInfoDataBW.write(createdUsername.getText());
						clientInfoDataBW.write(strReadCheckingBalance[0]);
						clientInfoDataBW.newLine();
						clientInfoDataBW.close();}
					catch (IOException ioe) 
						{
						JOptionPane.showMessageDialog(bankMachineSim.this,
													"Problem Writing to file. "+
													"IOException: " + ioe.getMessage());
						}
					JOptionPane.showMessageDialog (bankMachineSim.this, "New Balance: $"+strReadCheckingBalance[0]); withdrawCheckingDisplay.setVisible(false); titleDisplay.setVisible(false); getContentPane().add( cashConfirmDisplay );}});
		
		//****************************************************Withdraw Cash confirm display -Savings ACC
    	JPanel cashConfirmDisplay2 = new JPanel(new GridLayout (0,1));
    	cashConfirmDisplay2.setPreferredSize(new Dimension(880, 620));
    	//cashConfirmDisplay2.setBorder(BorderFactory.createLineBorder( Color.orange.darker() ));
    	cashConfirmDisplay2.setBackground( Color.gray );
		//cashConfirmDisplay2.add(new Label(""));
				
		JLabel cashConfDisplay2 = new JLabel("Please tap below to simulate cash being removed: ");
		cashConfDisplay2.setFont(new Font("Arial", Font.BOLD, 24));
      	cashConfirmDisplay2.add( cashConfDisplay2 );
    	                
    	//Creates an image
      	Icon grabCashpic2 = new ImageIcon( "cashpic.PNG" );
      	JButton cashpicture2 = new JButton(grabCashpic2);
      	cashConfirmDisplay2.add( cashpicture2 );//Adds to container
		
		//****************************************************Withdraw Cash action listeners -Savings ACC
		the20Key2.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ 
					savingsBalance = Double.parseDouble(strReadSavingsBalance[0]);
					savingsBalance = savingsBalance - 20;
					strReadSavingsBalance[0] = String.valueOf(savingsBalance);
					clientInfoSavingsBal = new File ("clientInfoSavingsBalance.txt"); 
					try
						{clientInfoDataFW = new FileWriter (clientInfoSavingsBal);
						clientInfoDataBW = new BufferedWriter (clientInfoDataFW);
						//clientInfoDataBW.newLine();
						//clientInfoDataBW.write(createdUsername.getText());
						clientInfoDataBW.write(strReadSavingsBalance[0]);
						clientInfoDataBW.newLine();
						clientInfoDataBW.close();}
					catch (IOException ioe) 
						{
						JOptionPane.showMessageDialog(bankMachineSim.this,
													"Problem Writing to file. "+
													"IOException: " + ioe.getMessage());
						}
					JOptionPane.showMessageDialog (bankMachineSim.this, "New Balance: $"+strReadSavingsBalance[0]); withdrawSavingsDisplay.setVisible(false); titleDisplay2.setVisible(false); getContentPane().add( cashConfirmDisplay2 );}});
		the40Key2.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ 
					savingsBalance = Double.parseDouble(strReadSavingsBalance[0]);
					savingsBalance = savingsBalance - 40;
					strReadSavingsBalance[0] = String.valueOf(savingsBalance);
					clientInfoSavingsBal = new File ("clientInfoSavingsBalance.txt"); 
					try
						{clientInfoDataFW = new FileWriter (clientInfoSavingsBal);
						clientInfoDataBW = new BufferedWriter (clientInfoDataFW);
						//clientInfoDataBW.newLine();
						//clientInfoDataBW.write(createdUsername.getText());
						clientInfoDataBW.write(strReadSavingsBalance[0]);
						clientInfoDataBW.newLine();
						clientInfoDataBW.close();}
					catch (IOException ioe) 
						{
						JOptionPane.showMessageDialog(bankMachineSim.this,
													"Problem Writing to file. "+
													"IOException: " + ioe.getMessage());
						} 
					JOptionPane.showMessageDialog (bankMachineSim.this, "New Balance: $"+strReadSavingsBalance[0]); withdrawSavingsDisplay.setVisible(false); titleDisplay2.setVisible(false); getContentPane().add( cashConfirmDisplay2 );}});
		the60Key2.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ 
					savingsBalance = Double.parseDouble(strReadSavingsBalance[0]);
					savingsBalance = savingsBalance - 60;
					strReadSavingsBalance[0] = String.valueOf(savingsBalance);
					clientInfoSavingsBal = new File ("clientInfoSavingsBalance.txt"); 
					try
						{clientInfoDataFW = new FileWriter (clientInfoSavingsBal);
						clientInfoDataBW = new BufferedWriter (clientInfoDataFW);
						//clientInfoDataBW.newLine();
						//clientInfoDataBW.write(createdUsername.getText());
						clientInfoDataBW.write(strReadSavingsBalance[0]);
						clientInfoDataBW.newLine();
						clientInfoDataBW.close();}
					catch (IOException ioe) 
						{
						JOptionPane.showMessageDialog(bankMachineSim.this,
													"Problem Writing to file. "+
													"IOException: " + ioe.getMessage());
						} 
					JOptionPane.showMessageDialog (bankMachineSim.this, "New Balance: $"+strReadSavingsBalance[0]); withdrawSavingsDisplay.setVisible(false); titleDisplay2.setVisible(false); getContentPane().add( cashConfirmDisplay2 );}});
		the80Key2.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ 
					savingsBalance = Double.parseDouble(strReadSavingsBalance[0]);
					savingsBalance = savingsBalance - 80;
					strReadSavingsBalance[0] = String.valueOf(savingsBalance);
					clientInfoSavingsBal = new File ("clientInfoSavingsBalance.txt"); 
					try
						{clientInfoDataFW = new FileWriter (clientInfoSavingsBal);
						clientInfoDataBW = new BufferedWriter (clientInfoDataFW);
						//clientInfoDataBW.newLine();
						//clientInfoDataBW.write(createdUsername.getText());
						clientInfoDataBW.write(strReadSavingsBalance[0]);
						clientInfoDataBW.newLine();
						clientInfoDataBW.close();}
					catch (IOException ioe) 
						{
						JOptionPane.showMessageDialog(bankMachineSim.this,
													"Problem Writing to file. "+
													"IOException: " + ioe.getMessage());
						}
					JOptionPane.showMessageDialog (bankMachineSim.this, "New Balance: $"+strReadSavingsBalance[0]); withdrawSavingsDisplay.setVisible(false); titleDisplay2.setVisible(false); getContentPane().add( cashConfirmDisplay2 );}});
		the100Key2.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ 
					savingsBalance = Double.parseDouble(strReadSavingsBalance[0]);
					savingsBalance = savingsBalance - 100;
					strReadSavingsBalance[0] = String.valueOf(savingsBalance);
					clientInfoSavingsBal = new File ("clientInfoSavingsBalance.txt"); 
					try
						{clientInfoDataFW = new FileWriter (clientInfoSavingsBal);
						clientInfoDataBW = new BufferedWriter (clientInfoDataFW);
						//clientInfoDataBW.newLine();
						//clientInfoDataBW.write(createdUsername.getText());
						clientInfoDataBW.write(strReadSavingsBalance[0]);
						clientInfoDataBW.newLine();
						clientInfoDataBW.close();}
					catch (IOException ioe) 
						{
						JOptionPane.showMessageDialog(bankMachineSim.this,
													"Problem Writing to file. "+
													"IOException: " + ioe.getMessage());
						}
					JOptionPane.showMessageDialog (bankMachineSim.this, "New Balance: $"+strReadSavingsBalance[0]); withdrawSavingsDisplay.setVisible(false); titleDisplay2.setVisible(false); getContentPane().add( cashConfirmDisplay2 );}});
		the120Key2.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ 
					savingsBalance = Double.parseDouble(strReadSavingsBalance[0]);
					savingsBalance = savingsBalance - 120;
					strReadSavingsBalance[0] = String.valueOf(savingsBalance);
					clientInfoSavingsBal = new File ("clientInfoSavingsBalance.txt"); 
					try
						{clientInfoDataFW = new FileWriter (clientInfoSavingsBal);
						clientInfoDataBW = new BufferedWriter (clientInfoDataFW);
						//clientInfoDataBW.newLine();
						//clientInfoDataBW.write(createdUsername.getText());
						clientInfoDataBW.write(strReadSavingsBalance[0]);
						clientInfoDataBW.newLine();
						clientInfoDataBW.close();}
					catch (IOException ioe) 
						{
						JOptionPane.showMessageDialog(bankMachineSim.this,
													"Problem Writing to file. "+
													"IOException: " + ioe.getMessage());
						}
					JOptionPane.showMessageDialog (bankMachineSim.this, "New Balance: $"+strReadSavingsBalance[0]); withdrawSavingsDisplay.setVisible(false); titleDisplay2.setVisible(false); getContentPane().add( cashConfirmDisplay2 );}});
		the140Key2.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ 
					savingsBalance = Double.parseDouble(strReadSavingsBalance[0]);
					savingsBalance = savingsBalance - 140;
					strReadSavingsBalance[0] = String.valueOf(savingsBalance);
					clientInfoSavingsBal = new File ("clientInfoSavingsBalance.txt"); 
					try
						{clientInfoDataFW = new FileWriter (clientInfoSavingsBal);
						clientInfoDataBW = new BufferedWriter (clientInfoDataFW);
						//clientInfoDataBW.newLine();
						//clientInfoDataBW.write(createdUsername.getText());
						clientInfoDataBW.write(strReadSavingsBalance[0]);
						clientInfoDataBW.newLine();
						clientInfoDataBW.close();}
					catch (IOException ioe) 
						{
						JOptionPane.showMessageDialog(bankMachineSim.this,
													"Problem Writing to file. "+
													"IOException: " + ioe.getMessage());
						}
					JOptionPane.showMessageDialog (bankMachineSim.this, "New Balance: $"+strReadSavingsBalance[0]); withdrawSavingsDisplay.setVisible(false); titleDisplay2.setVisible(false); getContentPane().add( cashConfirmDisplay2 );}});
		the160Key2.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ 
					savingsBalance = Double.parseDouble(strReadSavingsBalance[0]);
					savingsBalance = savingsBalance - 160;
					strReadSavingsBalance[0] = String.valueOf(savingsBalance);
					clientInfoSavingsBal = new File ("clientInfoSavingsBalance.txt"); 
					try
						{clientInfoDataFW = new FileWriter (clientInfoSavingsBal);
						clientInfoDataBW = new BufferedWriter (clientInfoDataFW);
						//clientInfoDataBW.newLine();
						//clientInfoDataBW.write(createdUsername.getText());
						clientInfoDataBW.write(strReadSavingsBalance[0]);
						clientInfoDataBW.newLine();
						clientInfoDataBW.close();}
					catch (IOException ioe) 
						{
						JOptionPane.showMessageDialog(bankMachineSim.this,
													"Problem Writing to file. "+
													"IOException: " + ioe.getMessage());
						}
					JOptionPane.showMessageDialog (bankMachineSim.this, "New Balance: $"+strReadSavingsBalance[0]); withdrawSavingsDisplay.setVisible(false); titleDisplay2.setVisible(false); getContentPane().add( cashConfirmDisplay2 );}});
					
		//****************************************************Receipt? and logout -- Checking ACC
    	JPanel reclogoutDisplay = new JPanel(new GridLayout (0,1));
    	reclogoutDisplay.setPreferredSize(new Dimension(700, 700));
    	//reclogoutDisplay.setBorder(BorderFactory.createLineBorder( Color.orange.darker() ));
    	reclogoutDisplay.setBackground( Color.gray );
		reclogoutDisplay.add(new Label(""));
				
		JLabel endDisplay = new JLabel("Please select one of the options below: ");
		endDisplay.setFont(new Font("Arial", Font.BOLD, 24));
      	reclogoutDisplay.add( endDisplay );
		
		reclogoutDisplay.add(new Label(""));
		JButton showBalanceW = new JButton("Show Receipt");
		showBalanceW.setFont(new Font("Arial", Font.BOLD, 40));
      	reclogoutDisplay.add( showBalanceW );//Adds to container
		
		reclogoutDisplay.add(new Label(""));
		JButton showlogoutW = new JButton("Finish/Logout");
		showlogoutW.setFont(new Font("Arial", Font.BOLD, 40));
      	reclogoutDisplay.add( showlogoutW );//Adds to container
		
		cashpicture.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ cashConfirmDisplay.setVisible(false); getContentPane().add( reclogoutDisplay );}});

		showBalanceW.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ JOptionPane.showMessageDialog (bankMachineSim.this, "New Balance: $"+strReadCheckingBalance[0]);}});

		showlogoutW.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ JOptionPane.showMessageDialog (bankMachineSim.this, "Thank you for using virtual bank machine!"); System.exit( 0 ); }});

		//****************************************************Receipt? and logout -- Savings ACC
    	JPanel reclogoutDisplay2 = new JPanel(new GridLayout (0,1));
    	reclogoutDisplay2.setPreferredSize(new Dimension(700, 700));
    	//reclogoutDisplay2.setBorder(BorderFactory.createLineBorder( Color.orange.darker() ));
    	reclogoutDisplay2.setBackground( Color.gray );
		reclogoutDisplay2.add(new Label(""));
				
		JLabel endDisplay2 = new JLabel("Please select one of the options below: ");
		endDisplay2.setFont(new Font("Arial", Font.BOLD, 24));
      	reclogoutDisplay2.add( endDisplay2 );
		
		reclogoutDisplay2.add(new Label(""));
		JButton showBalanceW2 = new JButton("Show Receipt");
		showBalanceW2.setFont(new Font("Arial", Font.BOLD, 40));
      	reclogoutDisplay2.add( showBalanceW2 );//Adds to container
		
		reclogoutDisplay2.add(new Label(""));
		JButton showlogoutW2 = new JButton("Finish/Logout");
		showlogoutW2.setFont(new Font("Arial", Font.BOLD, 40));
      	reclogoutDisplay2.add( showlogoutW2 );//Adds to container
		
		cashpicture2.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ cashConfirmDisplay2.setVisible(false); getContentPane().add( reclogoutDisplay2 );}});

		showBalanceW2.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ JOptionPane.showMessageDialog (bankMachineSim.this, "New Balance: $"+strReadSavingsBalance[0]);}});

		showlogoutW2.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ JOptionPane.showMessageDialog (bankMachineSim.this, "Thank you for using virtual bank machine!"); System.exit( 0 ); }});
		
		
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Deposit section
		
		
		//****************************************************Deposit from checking display
    	JPanel depositCheckingDisplay = new JPanel(new GridLayout (0,1));
    	depositCheckingDisplay.setPreferredSize(new Dimension(700, 300));
    	//depositCheckingDisplay.setBorder(BorderFactory.createLineBorder( Color.orange.darker() ));
    	depositCheckingDisplay.setBackground( Color.gray );
		//depositCheckingDisplay.add(new Label(""));
		depositCheckingDisplay.add(new Label(""));		
		JLabel actDisplay5 = new JLabel("<html>Deposit cash or cheque to Checking Account <br>Please select amount:</html>");
		actDisplay5.setFont(new Font("Arial", Font.BOLD, 24));
      	depositCheckingDisplay.add( actDisplay5 );
		//depositCheckingDisplay.add(new Label(""));
		
		depositAmount = new JTextField (16);
		depositAmount.setFont(new Font("Arial", Font.BOLD, 30));
		depositAmount.setEditable(false);
 		depositCheckingDisplay.add (depositAmount);
		depositCheckingDisplay.add(new Label(""));
		//****************************************************Deposit checking num pad
		JButton[] depCheckNumButtons = new JButton[10];
		for (int i = 0; i < depCheckNumButtons.length; i++) {
			depCheckNumButtons[i] = new JButton("" + i);
		}
		//number pad
		JPanel depCheckNumPad = new JPanel();
		depCheckNumPad.setLayout(new GridLayout(4, 3));
		depCheckNumPad.setPreferredSize(new Dimension(400, 400));
		for (int i = 1; i <= 9; i++) {
			depCheckNumButtons[i].setFont(new Font("Arial", Font.BOLD, 40));
			depCheckNumPad.add(depCheckNumButtons[i]);
		}
		depCheckNumPad.add(new Label(""));
		JButton aDot = new JButton(".");
		aDot.setFont(new Font("Arial", Font.BOLD, 40));
		depCheckNumButtons[0].setFont(new Font("Arial", Font.BOLD, 40));
		depCheckNumPad.add(depCheckNumButtons[0]);
		depCheckNumPad.add(aDot);
		//depCheckNumPad.add(new Label(""));
		//****************************************************

		//****************************************************Deposit checking edit keys
    	JPanel depEditKeys = new JPanel(new GridLayout (0,1));
    	depEditKeys.setPreferredSize(new Dimension(250, 400));
    	//depEditKeys.setBorder(BorderFactory.createLineBorder( Color.orange.darker() ));
    	depEditKeys.setBackground( Color.gray );
		//JButton accCancelKey = new JButton("CANCEL");
		//accCancelKey.setBackground( Color.red );
		//accCancelKey.setFont(new Font("Arial", Font.BOLD, 40));
		JButton depClearKey = new JButton("CLEAR");
		depClearKey.setBackground( Color.yellow );
		depClearKey.setFont(new Font("Arial", Font.BOLD, 40));
		JButton depEnterKey = new JButton("ENTER");
		depEnterKey.setBackground( Color.green );
		depEnterKey.setFont(new Font("Arial", Font.BOLD, 40));
		//depEditKeys.add(accCancelKey);
		depEditKeys.add(depClearKey);
		depEditKeys.add(depEnterKey);
		depEditKeys.add(new Label(""));
		
		depositCheckingKey.addActionListener(new ActionListener()
				{
					//Actions when login button is clicked
					public void actionPerformed(ActionEvent e)
					{         
						depositDisplay.setVisible(false);
						getContentPane().add( depositCheckingDisplay );
						getContentPane().add( depCheckNumPad );
						getContentPane().add( depEditKeys );

					}
				}
			
			);
        
		//****************************************************Deposit Money confirm display - CHECKING ACC
    	JPanel depositConfirmDisplay = new JPanel(new GridLayout (0,1));
    	depositConfirmDisplay.setPreferredSize(new Dimension(880, 620));
    	//depositConfirmDisplay.setBorder(BorderFactory.createLineBorder( Color.orange.darker() ));
    	depositConfirmDisplay.setBackground( Color.gray );
		//depositConfirmDisplay.add(new Label(""));
				
		JLabel depConfDisplay = new JLabel("Please tap below to simulate a sealed envelope being inserted: ");
		depConfDisplay.setFont(new Font("Arial", Font.BOLD, 24));
      	depositConfirmDisplay.add( depConfDisplay );
    	                
    	//Creates an image
      	Icon InsertEnveloppic = new ImageIcon( "insertEnvelope.PNG" );
      	JButton envelopePicture = new JButton(InsertEnveloppic);
      	depositConfirmDisplay.add( envelopePicture );//Adds to container
		
		 		//****************************************************deposit acc action listener - CHECKING ACC
		depCheckNumButtons[0].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ depositAmount.setText(depositAmount.getText() + depCheckNumButtons[0].getText()); }});
		depCheckNumButtons[1].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ depositAmount.setText(depositAmount.getText() + depCheckNumButtons[1].getText()); }});
		depCheckNumButtons[2].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ depositAmount.setText(depositAmount.getText() + depCheckNumButtons[2].getText()); }});
		depCheckNumButtons[3].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ depositAmount.setText(depositAmount.getText() + depCheckNumButtons[3].getText()); }});
		depCheckNumButtons[4].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ depositAmount.setText(depositAmount.getText() + depCheckNumButtons[4].getText()); }});
		depCheckNumButtons[5].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ depositAmount.setText(depositAmount.getText() + depCheckNumButtons[5].getText()); }});
		depCheckNumButtons[6].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ depositAmount.setText(depositAmount.getText() + depCheckNumButtons[6].getText()); }});
		depCheckNumButtons[7].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ depositAmount.setText(depositAmount.getText() + depCheckNumButtons[7].getText()); }});
		depCheckNumButtons[8].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ depositAmount.setText(depositAmount.getText() + depCheckNumButtons[8].getText()); }});
		depCheckNumButtons[9].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ depositAmount.setText(depositAmount.getText() + depCheckNumButtons[9].getText()); }});
		aDot.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ depositAmount.setText(depositAmount.getText() + aDot.getText()); }});						
		
		depClearKey.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ depositAmount.setText(""); }});

		depEnterKey.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ depositValue = Double.parseDouble(depositAmount.getText()); 
																checkingBalance = Double.parseDouble(strReadCheckingBalance[0]);
																checkingBalance = checkingBalance + depositValue;
																
																roundOff = (double) Math.round(checkingBalance * 100) / 100;
																checkingBalance = roundOff;
																
																strReadCheckingBalance[0] = String.valueOf(checkingBalance);
																JOptionPane.showMessageDialog (bankMachineSim.this, "You have successfully entered your deposit value: $"+depositValue+" \nYour new balance is: $"+strReadCheckingBalance[0]);
																clientInfoCheckingBal = new File ("clientInfoCheckingBalance.txt"); 
																try
																	{clientInfoDataFW = new FileWriter (clientInfoCheckingBal);
																	clientInfoDataBW = new BufferedWriter (clientInfoDataFW);
																	//clientInfoDataBW.newLine();
																	//clientInfoDataBW.write(createdUsername.getText());
																	clientInfoDataBW.write(strReadCheckingBalance[0]);
																	clientInfoDataBW.newLine();
																	clientInfoDataBW.close();}
																catch (IOException ioe) 
																	{
																	JOptionPane.showMessageDialog(bankMachineSim.this,
																								"Problem Writing to file. "+
																								"IOException: " + ioe.getMessage());
																	}
																depositCheckingDisplay.setVisible(false);
																depCheckNumPad.setVisible(false);
																depEditKeys.setVisible(false);
																getContentPane().add( depositConfirmDisplay );
																	}});
		
		//****************************************************Receipt? and logout -- Checking ACC -deposit
    	JPanel reclogoutDisplay3 = new JPanel(new GridLayout (0,1));
    	reclogoutDisplay3.setPreferredSize(new Dimension(700, 700));
    	//reclogoutDisplay3.setBorder(BorderFactory.createLineBorder( Color.orange.darker() ));
    	reclogoutDisplay3.setBackground( Color.gray );
		reclogoutDisplay3.add(new Label(""));
				
		JLabel endDisplay3 = new JLabel("Please select one of the options below: ");
		endDisplay3.setFont(new Font("Arial", Font.BOLD, 24));
      	reclogoutDisplay3.add( endDisplay3 );
		
		reclogoutDisplay3.add(new Label(""));
		JButton showBalanceD1 = new JButton("Show Receipt");
		showBalanceD1.setFont(new Font("Arial", Font.BOLD, 40));
      	reclogoutDisplay3.add( showBalanceD1 );//Adds to container
		
		reclogoutDisplay3.add(new Label(""));
		JButton showlogoutD1 = new JButton("Finish/Logout");
		showlogoutD1.setFont(new Font("Arial", Font.BOLD, 40));
      	reclogoutDisplay3.add( showlogoutD1 );//Adds to container
		
		envelopePicture.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ depositConfirmDisplay.setVisible(false); getContentPane().add( reclogoutDisplay3 );}});	

		showBalanceD1.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ JOptionPane.showMessageDialog (bankMachineSim.this, "New Checking Balance: $"+strReadCheckingBalance[0]);}});

		showlogoutD1.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ JOptionPane.showMessageDialog (bankMachineSim.this, "Thank you for using virtual bank machine!"); System.exit( 0 ); }});
		
										
		
		///////////////////////////////////////////////////////////////////////////////////////////////////////888888888888888888888888888888888888888		
		//****************************************************Deposit from Savings display
    	JPanel depositSavingsDisplay = new JPanel(new GridLayout (0,1));
    	depositSavingsDisplay.setPreferredSize(new Dimension(700, 300));
    	//depositSavingsDisplay.setBorder(BorderFactory.createLineBorder( Color.orange.darker() ));
    	depositSavingsDisplay.setBackground( Color.gray );
		//depositSavingsDisplay.add(new Label(""));
		depositSavingsDisplay.add(new Label(""));		
		JLabel act2Display5 = new JLabel("<html>Deposit cash or cheque to Savings Account <br>Please select amount:</html>");
		act2Display5.setFont(new Font("Arial", Font.BOLD, 24));
      	depositSavingsDisplay.add( act2Display5 );
		//depositSavingsDisplay.add(new Label(""));
		
		depositAmount2 = new JTextField (16);
		depositAmount2.setFont(new Font("Arial", Font.BOLD, 30));
		depositAmount2.setEditable(false);
 		depositSavingsDisplay.add (depositAmount2);
		depositSavingsDisplay.add(new Label(""));
		//****************************************************Deposit Savings num pad
		JButton[] depSavingsNumButtons = new JButton[10];
		for (int i = 0; i < depSavingsNumButtons.length; i++) {
			depSavingsNumButtons[i] = new JButton("" + i);
		}
		//number pad
		JPanel depSavingsNumPad = new JPanel();
		depSavingsNumPad.setLayout(new GridLayout(4, 3));
		depSavingsNumPad.setPreferredSize(new Dimension(400, 400));
		for (int i = 1; i <= 9; i++) {
			depSavingsNumButtons[i].setFont(new Font("Arial", Font.BOLD, 40));
			depSavingsNumPad.add(depSavingsNumButtons[i]);
		}
		depSavingsNumPad.add(new Label(""));
		JButton aDot2 = new JButton(".");
		aDot2.setFont(new Font("Arial", Font.BOLD, 40));
		depSavingsNumButtons[0].setFont(new Font("Arial", Font.BOLD, 40));
		depSavingsNumPad.add(depSavingsNumButtons[0]);
		depSavingsNumPad.add(aDot2);
		//depSavingsNumPad.add(new Label(""));
		//****************************************************

		//****************************************************Deposit Savings edit keys
    	JPanel depEditKeys2 = new JPanel(new GridLayout (0,1));
    	depEditKeys2.setPreferredSize(new Dimension(250, 400));
    	//depEditKeys2.setBorder(BorderFactory.createLineBorder( Color.orange.darker() ));
    	depEditKeys2.setBackground( Color.gray );
		//JButton accCancelKey2 = new JButton("CANCEL");
		//accCancelKey2.setBackground( Color.red );
		//accCancelKey2.setFont(new Font("Arial", Font.BOLD, 40));
		JButton depClearKey2 = new JButton("CLEAR");
		depClearKey2.setBackground( Color.yellow );
		depClearKey2.setFont(new Font("Arial", Font.BOLD, 40));
		JButton depEnterKey2 = new JButton("ENTER");
		depEnterKey2.setBackground( Color.green );
		depEnterKey2.setFont(new Font("Arial", Font.BOLD, 40));
		//depEditKeys2.add(accCancelKey2);
		depEditKeys2.add(depClearKey2);
		depEditKeys2.add(depEnterKey2);
		depEditKeys2.add(new Label(""));
		
		depositSavingsKey.addActionListener(new ActionListener()
				{
					//Actions when login button is clicked
					public void actionPerformed(ActionEvent e)
					{         
						depositDisplay.setVisible(false);
						getContentPane().add( depositSavingsDisplay );
						getContentPane().add( depSavingsNumPad );
						getContentPane().add( depEditKeys2 );

					}
				}
			
			);
        
		//****************************************************Deposit Money confirm display - Savings ACC
    	JPanel depositConfirmDisplay2 = new JPanel(new GridLayout (0,1));
    	depositConfirmDisplay2.setPreferredSize(new Dimension(880, 620));
    	//depositConfirmDisplay2.setBorder(BorderFactory.createLineBorder( Color.orange.darker() ));
    	depositConfirmDisplay2.setBackground( Color.gray );
		//depositConfirmDisplay2.add(new Label(""));
				
		JLabel depConfDisplay2 = new JLabel("Please tap below to simulate a sealed envelope being inserted: ");
		depConfDisplay2.setFont(new Font("Arial", Font.BOLD, 24));
      	depositConfirmDisplay2.add( depConfDisplay2 );
    	                
    	//Creates an image
      	Icon InsertEnveloppic2 = new ImageIcon( "insertEnvelope.PNG" );
      	JButton envelopePicture2 = new JButton(InsertEnveloppic2);
      	depositConfirmDisplay2.add( envelopePicture2 );//Adds to container
		
		 		//****************************************************deposit acc action listener - Savings ACC
		depSavingsNumButtons[0].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ depositAmount2.setText(depositAmount2.getText() + depSavingsNumButtons[0].getText()); }});
		depSavingsNumButtons[1].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ depositAmount2.setText(depositAmount2.getText() + depSavingsNumButtons[1].getText()); }});
		depSavingsNumButtons[2].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ depositAmount2.setText(depositAmount2.getText() + depSavingsNumButtons[2].getText()); }});
		depSavingsNumButtons[3].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ depositAmount2.setText(depositAmount2.getText() + depSavingsNumButtons[3].getText()); }});
		depSavingsNumButtons[4].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ depositAmount2.setText(depositAmount2.getText() + depSavingsNumButtons[4].getText()); }});
		depSavingsNumButtons[5].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ depositAmount2.setText(depositAmount2.getText() + depSavingsNumButtons[5].getText()); }});
		depSavingsNumButtons[6].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ depositAmount2.setText(depositAmount2.getText() + depSavingsNumButtons[6].getText()); }});
		depSavingsNumButtons[7].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ depositAmount2.setText(depositAmount2.getText() + depSavingsNumButtons[7].getText()); }});
		depSavingsNumButtons[8].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ depositAmount2.setText(depositAmount2.getText() + depSavingsNumButtons[8].getText()); }});
		depSavingsNumButtons[9].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ depositAmount2.setText(depositAmount2.getText() + depSavingsNumButtons[9].getText()); }});
		aDot2.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ depositAmount2.setText(depositAmount2.getText() + aDot2.getText()); }});						
		
		depClearKey2.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ depositAmount2.setText(""); }});

		depEnterKey2.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ depositValue = Double.parseDouble(depositAmount2.getText()); 
																savingsBalance = Double.parseDouble(strReadSavingsBalance[0]);
																savingsBalance = savingsBalance + depositValue;
																
																roundOff = (double) Math.round(savingsBalance * 100) / 100;
																savingsBalance = roundOff;
																
																strReadSavingsBalance[0] = String.valueOf(savingsBalance);
																JOptionPane.showMessageDialog (bankMachineSim.this, "You have successfully entered your deposit value: $"+depositValue+" \nYour new balance is: $"+strReadSavingsBalance[0]);
																clientInfoCheckingBal = new File ("clientInfoSavingsBalance.txt"); 
																try
																	{clientInfoDataFW = new FileWriter (clientInfoCheckingBal);
																	clientInfoDataBW = new BufferedWriter (clientInfoDataFW);
																	//clientInfoDataBW.newLine();
																	//clientInfoDataBW.write(createdUsername.getText());
																	clientInfoDataBW.write(strReadSavingsBalance[0]);
																	clientInfoDataBW.newLine();
																	clientInfoDataBW.close();}
																catch (IOException ioe) 
																	{
																	JOptionPane.showMessageDialog(bankMachineSim.this,
																								"Problem Writing to file. "+
																								"IOException: " + ioe.getMessage());
																	}
																depositSavingsDisplay.setVisible(false);
																depSavingsNumPad.setVisible(false);
																depEditKeys2.setVisible(false);
																getContentPane().add( depositConfirmDisplay2 );
																	}});
		
		//****************************************************Receipt? and logout -- Savings ACC -deposit
    	JPanel reclogoutDisplay4 = new JPanel(new GridLayout (0,1));
    	reclogoutDisplay4.setPreferredSize(new Dimension(700, 700));
    	//reclogoutDisplay4.setBorder(BorderFactory.createLineBorder( Color.orange.darker() ));
    	reclogoutDisplay4.setBackground( Color.gray );
		reclogoutDisplay4.add(new Label(""));
				
		JLabel endDisplay4 = new JLabel("Please select one of the options below: ");
		endDisplay4.setFont(new Font("Arial", Font.BOLD, 24));
      	reclogoutDisplay4.add( endDisplay4 );
		
		reclogoutDisplay4.add(new Label(""));
		JButton showBalanceD2 = new JButton("Show Receipt");
		showBalanceD2.setFont(new Font("Arial", Font.BOLD, 40));
      	reclogoutDisplay4.add( showBalanceD2 );//Adds to container
		
		reclogoutDisplay4.add(new Label(""));
		JButton showlogoutD2 = new JButton("Finish/Logout");
		showlogoutD2.setFont(new Font("Arial", Font.BOLD, 40));
      	reclogoutDisplay4.add( showlogoutD2 );//Adds to container
		
		envelopePicture2.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ depositConfirmDisplay2.setVisible(false); getContentPane().add( reclogoutDisplay4 );}});	

		showBalanceD2.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ JOptionPane.showMessageDialog (bankMachineSim.this, "New Savings Balance: $"+strReadSavingsBalance[0]);}});

		showlogoutD2.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ JOptionPane.showMessageDialog (bankMachineSim.this, "Thank you for using virtual bank machine!"); System.exit( 0 ); }});
					
					
		//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\\\\\\\\
				//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\\\\\\\\

						//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\\\\\\\\

		//****************************************************Transfer from account display
    	JPanel transferFromDisplay = new JPanel(new GridLayout (0,1));
    	transferFromDisplay.setPreferredSize(new Dimension(750, 800));
    	//transferFromDisplay.setBorder(BorderFactory.createLineBorder( Color.orange.darker() ));
    	transferFromDisplay.setBackground( Color.gray );
		transferFromDisplay.add(new Label(""));
				
		JLabel actDisplayy = new JLabel("Please Select an Account to Transfer Money from:");
		actDisplayy.setFont(new Font("Arial", Font.BOLD, 24));
      	transferFromDisplay.add( actDisplayy );
		transferFromDisplay.add(new Label(""));
    	JButton transferCheckingKey = new JButton("Checking Account");
		transferCheckingKey.setFont(new Font("Arial", Font.BOLD, 40));
		JButton tranferSavingsKey = new JButton("Savings Account");
		tranferSavingsKey.setFont(new Font("Arial", Font.BOLD, 40));
		
		transferFromDisplay.add(transferCheckingKey);
		transferFromDisplay.add(new Label(""));
		transferFromDisplay.add(tranferSavingsKey);
		transferFromDisplay.add(new Label(""));


		
		transferKey.addActionListener(new ActionListener()
				{
					//Actions when login button is clicked
					public void actionPerformed(ActionEvent e)
					{         
						actionDisplay.setVisible(false);
						getContentPane().add( transferFromDisplay );

					}
				}
			
			);
		
		//****************************************************Transfer from checking display
    	JPanel transferCheckingDisplay = new JPanel(new GridLayout (0,1));
    	transferCheckingDisplay.setPreferredSize(new Dimension(700, 300));
    	//transferCheckingDisplay.setBorder(BorderFactory.createLineBorder( Color.orange.darker() ));
    	transferCheckingDisplay.setBackground( Color.gray );
		//transferCheckingDisplay.add(new Label(""));
		transferCheckingDisplay.add(new Label(""));		
		JLabel actDisplayy11 = new JLabel("<html>Transfer money from Checking to Savings Account <br>Please select amount:</html>");
		actDisplayy11.setFont(new Font("Arial", Font.BOLD, 24));
      	transferCheckingDisplay.add( actDisplayy11 );
		//transferCheckingDisplay.add(new Label(""));
		
		tranferAmount = new JTextField (16);
		tranferAmount.setFont(new Font("Arial", Font.BOLD, 30));
		tranferAmount.setEditable(false);
 		transferCheckingDisplay.add (tranferAmount);
		transferCheckingDisplay.add(new Label(""));
		//****************************************************Transfer checking num pad
		JButton[] tranCheckNumButtons = new JButton[10];
		for (int i = 0; i < tranCheckNumButtons.length; i++) {
			tranCheckNumButtons[i] = new JButton("" + i);
		}
		//number pad
		JPanel tranCheckNumPad = new JPanel();
		tranCheckNumPad.setLayout(new GridLayout(4, 3));
		tranCheckNumPad.setPreferredSize(new Dimension(400, 400));
		for (int i = 1; i <= 9; i++) {
			tranCheckNumButtons[i].setFont(new Font("Arial", Font.BOLD, 40));
			tranCheckNumPad.add(tranCheckNumButtons[i]);
		}
		tranCheckNumPad.add(new Label(""));
		JButton aDottt = new JButton(".");
		aDottt.setFont(new Font("Arial", Font.BOLD, 40));
		tranCheckNumButtons[0].setFont(new Font("Arial", Font.BOLD, 40));
		tranCheckNumPad.add(tranCheckNumButtons[0]);
		tranCheckNumPad.add(aDottt);
		//tranCheckNumPad.add(new Label(""));
		//****************************************************

		//****************************************************Transfer checking edit keys
    	JPanel tranEditKeys = new JPanel(new GridLayout (0,1));
    	tranEditKeys.setPreferredSize(new Dimension(250, 400));
    	//tranEditKeys.setBorder(BorderFactory.createLineBorder( Color.orange.darker() ));
    	tranEditKeys.setBackground( Color.gray );
		//JButton accCancelKey = new JButton("CANCEL");
		//accCancelKey.setBackground( Color.red );
		//accCancelKey.setFont(new Font("Arial", Font.BOLD, 40));
		JButton tranClearKey = new JButton("CLEAR");
		tranClearKey.setBackground( Color.yellow );
		tranClearKey.setFont(new Font("Arial", Font.BOLD, 40));
		JButton tranEnterKey = new JButton("ENTER");
		tranEnterKey.setBackground( Color.green );
		tranEnterKey.setFont(new Font("Arial", Font.BOLD, 40));
		//tranEditKeys.add(accCancelKey);
		tranEditKeys.add(tranClearKey);
		tranEditKeys.add(tranEnterKey);
		tranEditKeys.add(new Label(""));
		
		transferCheckingKey.addActionListener(new ActionListener()
				{
					//Actions when login button is clicked
					public void actionPerformed(ActionEvent e)
					{         
						transferFromDisplay.setVisible(false);
						getContentPane().add( transferCheckingDisplay );
						getContentPane().add( tranCheckNumPad );
						getContentPane().add( tranEditKeys );

					}
				}
			
			);
		
		//****************************************************Receipt? and logout -- Checking ACC -transfer
    	JPanel reclogoutDisplayy = new JPanel(new GridLayout (0,1));
    	reclogoutDisplayy.setPreferredSize(new Dimension(700, 700));
    	//reclogoutDisplayy.setBorder(BorderFactory.createLineBorder( Color.orange.darker() ));
    	reclogoutDisplayy.setBackground( Color.gray );
		reclogoutDisplayy.add(new Label(""));
				
		JLabel endDisplayy = new JLabel("Please select one of the options below: ");
		endDisplayy.setFont(new Font("Arial", Font.BOLD, 24));
      	reclogoutDisplayy.add( endDisplayy );
		
		reclogoutDisplayy.add(new Label(""));
		JButton showBalanceT1 = new JButton("Show Receipt");
		showBalanceT1.setFont(new Font("Arial", Font.BOLD, 40));
      	reclogoutDisplayy.add( showBalanceT1 );//Adds to container
		
		reclogoutDisplayy.add(new Label(""));
		JButton showlogoutT1 = new JButton("Finish/Logout");
		showlogoutT1.setFont(new Font("Arial", Font.BOLD, 40));
      	reclogoutDisplayy.add( showlogoutT1 );//Adds to container
							
		//****************************************************transfer acc action listener - CHECKING ACC
		tranCheckNumButtons[0].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ tranferAmount.setText(tranferAmount.getText() + tranCheckNumButtons[0].getText()); }});
		tranCheckNumButtons[1].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ tranferAmount.setText(tranferAmount.getText() + tranCheckNumButtons[1].getText()); }});
		tranCheckNumButtons[2].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ tranferAmount.setText(tranferAmount.getText() + tranCheckNumButtons[2].getText()); }});
		tranCheckNumButtons[3].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ tranferAmount.setText(tranferAmount.getText() + tranCheckNumButtons[3].getText()); }});
		tranCheckNumButtons[4].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ tranferAmount.setText(tranferAmount.getText() + tranCheckNumButtons[4].getText()); }});
		tranCheckNumButtons[5].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ tranferAmount.setText(tranferAmount.getText() + tranCheckNumButtons[5].getText()); }});
		tranCheckNumButtons[6].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ tranferAmount.setText(tranferAmount.getText() + tranCheckNumButtons[6].getText()); }});
		tranCheckNumButtons[7].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ tranferAmount.setText(tranferAmount.getText() + tranCheckNumButtons[7].getText()); }});
		tranCheckNumButtons[8].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ tranferAmount.setText(tranferAmount.getText() + tranCheckNumButtons[8].getText()); }});
		tranCheckNumButtons[9].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ tranferAmount.setText(tranferAmount.getText() + tranCheckNumButtons[9].getText()); }});
		aDottt.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ tranferAmount.setText(tranferAmount.getText() + aDottt.getText()); }});						
		
		tranClearKey.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ tranferAmount.setText(""); }});

		tranEnterKey.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ tranferValue = Double.parseDouble(tranferAmount.getText()); 
																checkingBalance = Double.parseDouble(strReadCheckingBalance[0]);
																savingsBalance = Double.parseDouble(strReadSavingsBalance[0]);
																
																checkingBalance = checkingBalance - tranferValue;
																
																roundOff = (double) Math.round(checkingBalance * 100) / 100;
																checkingBalance = roundOff;
																
																savingsBalance = savingsBalance + tranferValue;
																
																roundOff = (double) Math.round(savingsBalance * 100) / 100;
																savingsBalance = roundOff;
																
																strReadCheckingBalance[0] = String.valueOf(checkingBalance);
																strReadSavingsBalance[0] = String.valueOf(savingsBalance);
																JOptionPane.showMessageDialog (bankMachineSim.this, "You have successfully entered your transfer value: $"+tranferValue+" \nYour new Checking Account balance is: $"+strReadCheckingBalance[0]+" \nYour new Savings Account balance is: $"+strReadSavingsBalance[0]);
																clientInfoCheckingBal = new File ("clientInfoCheckingBalance.txt"); 
																try
																	{clientInfoDataFW = new FileWriter (clientInfoCheckingBal);
																	clientInfoDataBW = new BufferedWriter (clientInfoDataFW);
																	//clientInfoDataBW.newLine();
																	//clientInfoDataBW.write(createdUsername.getText());
																	clientInfoDataBW.write(strReadCheckingBalance[0]);
																	clientInfoDataBW.newLine();
																	clientInfoDataBW.close();}
																catch (IOException ioe) 
																	{
																	JOptionPane.showMessageDialog(bankMachineSim.this,
																								"Problem Writing to file. "+
																								"IOException: " + ioe.getMessage());
																	}
																
																clientInfoSavingsBal = new File ("clientInfoSavingsBalance.txt"); 
																try
																	{clientInfoDataFW = new FileWriter (clientInfoSavingsBal);
																	clientInfoDataBW = new BufferedWriter (clientInfoDataFW);
																	//clientInfoDataBW.newLine();
																	//clientInfoDataBW.write(createdUsername.getText());
																	clientInfoDataBW.write(strReadSavingsBalance[0]);
																	clientInfoDataBW.newLine();
																	clientInfoDataBW.close();}
																catch (IOException ioe) 
																	{
																	JOptionPane.showMessageDialog(bankMachineSim.this,
																								"Problem Writing to file. "+
																								"IOException: " + ioe.getMessage());
																	}
																transferCheckingDisplay.setVisible(false);
																tranCheckNumPad.setVisible(false);
																tranEditKeys.setVisible(false);
																getContentPane().add( reclogoutDisplayy );
																	}});
																	
		// -------------------------------------------------------------------------------------------------------
		//----------------------------------------- receipt transfer and logout listeners
		showBalanceT1.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ JOptionPane.showMessageDialog (bankMachineSim.this, "New Checking Balance: $"+strReadCheckingBalance[0]+"\nNew Savings Balance: $"+strReadSavingsBalance[0]);}});

		showlogoutT1.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ JOptionPane.showMessageDialog (bankMachineSim.this, "Thank you for using virtual bank machine!"); System.exit( 0 ); }});
		
		///////////////////////////--------------------------------------------------------------------------------------------
		//////////////////////////-------------------------------------------------------------------------------------------0000000000000000000000000000000000000000000
		
		//****************************************************Transfer from savings display
    	JPanel transferSavingsDisplay = new JPanel(new GridLayout (0,1));
    	transferSavingsDisplay.setPreferredSize(new Dimension(700, 300));
    	//transferSavingsDisplay.setBorder(BorderFactory.createLineBorder( Color.orange.darker() ));
    	transferSavingsDisplay.setBackground( Color.gray );
		//transferSavingsDisplay.add(new Label(""));
		transferSavingsDisplay.add(new Label(""));		
		JLabel actDisplayy22 = new JLabel("<html>Transfer money from Savings to Checking Account <br>Please select amount:</html>");
		actDisplayy22.setFont(new Font("Arial", Font.BOLD, 24));
      	transferSavingsDisplay.add( actDisplayy22 );
		//transferSavingsDisplay.add(new Label(""));
		
		tranferAmount2 = new JTextField (16);
		tranferAmount2.setFont(new Font("Arial", Font.BOLD, 30));
		tranferAmount2.setEditable(false);
 		transferSavingsDisplay.add (tranferAmount2);
		transferSavingsDisplay.add(new Label(""));
		//****************************************************Transfer savings num pad
		JButton[] tranSavingsNumButtons = new JButton[10];
		for (int i = 0; i < tranSavingsNumButtons.length; i++) {
			tranSavingsNumButtons[i] = new JButton("" + i);
		}
		//number pad
		JPanel tranSavingsNumPad = new JPanel();
		tranSavingsNumPad.setLayout(new GridLayout(4, 3));
		tranSavingsNumPad.setPreferredSize(new Dimension(400, 400));
		for (int i = 1; i <= 9; i++) {
			tranSavingsNumButtons[i].setFont(new Font("Arial", Font.BOLD, 40));
			tranSavingsNumPad.add(tranSavingsNumButtons[i]);
		}
		tranSavingsNumPad.add(new Label(""));
		JButton aDott2 = new JButton(".");
		aDott2.setFont(new Font("Arial", Font.BOLD, 40));
		tranSavingsNumButtons[0].setFont(new Font("Arial", Font.BOLD, 40));
		tranSavingsNumPad.add(tranSavingsNumButtons[0]);
		tranSavingsNumPad.add(aDott2);
		//tranSavingsNumPad.add(new Label(""));
		//****************************************************

		//****************************************************Transfer savings edit keys
    	JPanel tranEditKeys2 = new JPanel(new GridLayout (0,1));
    	tranEditKeys2.setPreferredSize(new Dimension(250, 400));
    	//tranEditKeys2.setBorder(BorderFactory.createLineBorder( Color.orange.darker() ));
    	tranEditKeys2.setBackground( Color.gray );
		//JButton accCancelKey = new JButton("CANCEL");
		//accCancelKey.setBackground( Color.red );
		//accCancelKey.setFont(new Font("Arial", Font.BOLD, 40));
		JButton tranClearKey2 = new JButton("CLEAR");
		tranClearKey2.setBackground( Color.yellow );
		tranClearKey2.setFont(new Font("Arial", Font.BOLD, 40));
		JButton tranEnterKey2 = new JButton("ENTER");
		tranEnterKey2.setBackground( Color.green );
		tranEnterKey2.setFont(new Font("Arial", Font.BOLD, 40));
		//tranEditKeys2.add(accCancelKey);
		tranEditKeys2.add(tranClearKey2);
		tranEditKeys2.add(tranEnterKey2);
		tranEditKeys2.add(new Label(""));
		
		tranferSavingsKey.addActionListener(new ActionListener()
				{
					//Actions when login button is clicked
					public void actionPerformed(ActionEvent e)
					{         
						transferFromDisplay.setVisible(false);
						getContentPane().add( transferSavingsDisplay );
						getContentPane().add( tranSavingsNumPad );
						getContentPane().add( tranEditKeys2 );

					}
				}
			
			);
		
		//****************************************************Receipt? and logout -- savings ACC -transfer
    	JPanel reclogoutDisplayy2 = new JPanel(new GridLayout (0,1));
    	reclogoutDisplayy2.setPreferredSize(new Dimension(700, 750));
    	//reclogoutDisplayy2.setBorder(BorderFactory.createLineBorder( Color.orange.darker() ));
    	reclogoutDisplayy2.setBackground( Color.gray );
		reclogoutDisplayy2.add(new Label(""));
				
		JLabel endDisplayy2 = new JLabel("Please select one of the options below: ");
		endDisplayy2.setFont(new Font("Arial", Font.BOLD, 24));
      	reclogoutDisplayy2.add( endDisplayy2 );
		
		reclogoutDisplayy2.add(new Label(""));
		JButton showBalanceT2 = new JButton("Show Receipt");
		showBalanceT2.setFont(new Font("Arial", Font.BOLD, 40));
      	reclogoutDisplayy2.add( showBalanceT2 );//Adds to container
		
		reclogoutDisplayy2.add(new Label(""));
		JButton showlogoutT2 = new JButton("Logout");
		showlogoutT2.setFont(new Font("Arial", Font.BOLD, 40));
      	reclogoutDisplayy2.add( showlogoutT2 );//Adds to container
		
						
		//****************************************************transfer acc action listener - savings ACC
		tranSavingsNumButtons[0].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ tranferAmount2.setText(tranferAmount2.getText() + tranSavingsNumButtons[0].getText()); }});
		tranSavingsNumButtons[1].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ tranferAmount2.setText(tranferAmount2.getText() + tranSavingsNumButtons[1].getText()); }});
		tranSavingsNumButtons[2].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ tranferAmount2.setText(tranferAmount2.getText() + tranSavingsNumButtons[2].getText()); }});
		tranSavingsNumButtons[3].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ tranferAmount2.setText(tranferAmount2.getText() + tranSavingsNumButtons[3].getText()); }});
		tranSavingsNumButtons[4].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ tranferAmount2.setText(tranferAmount2.getText() + tranSavingsNumButtons[4].getText()); }});
		tranSavingsNumButtons[5].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ tranferAmount2.setText(tranferAmount2.getText() + tranSavingsNumButtons[5].getText()); }});
		tranSavingsNumButtons[6].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ tranferAmount2.setText(tranferAmount2.getText() + tranSavingsNumButtons[6].getText()); }});
		tranSavingsNumButtons[7].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ tranferAmount2.setText(tranferAmount2.getText() + tranSavingsNumButtons[7].getText()); }});
		tranSavingsNumButtons[8].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ tranferAmount2.setText(tranferAmount2.getText() + tranSavingsNumButtons[8].getText()); }});
		tranSavingsNumButtons[9].addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ tranferAmount2.setText(tranferAmount2.getText() + tranSavingsNumButtons[9].getText()); }});
		aDott2.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ tranferAmount2.setText(tranferAmount2.getText() + aDott2.getText()); }});						
		
		tranClearKey2.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ tranferAmount2.setText(""); }});

		tranEnterKey2.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ tranferValue2 = Double.parseDouble(tranferAmount2.getText()); 
																checkingBalance = Double.parseDouble(strReadCheckingBalance[0]);
																savingsBalance = Double.parseDouble(strReadSavingsBalance[0]);
																
																checkingBalance = checkingBalance + tranferValue2;
																
																roundOff = (double) Math.round(checkingBalance * 100) / 100;
																checkingBalance = roundOff;
																
																savingsBalance = savingsBalance - tranferValue2;
																
																roundOff = (double) Math.round(savingsBalance * 100) / 100;
																savingsBalance = roundOff;
																
																strReadCheckingBalance[0] = String.valueOf(checkingBalance);
																strReadSavingsBalance[0] = String.valueOf(savingsBalance);
																JOptionPane.showMessageDialog (bankMachineSim.this, "You have successfully entered your transfer value: $"+tranferValue2+" \nYour new Checking Account balance is: $"+strReadCheckingBalance[0]+" \nYour new Savings Account balance is: $"+strReadSavingsBalance[0]);
																clientInfoCheckingBal = new File ("clientInfoCheckingBalance.txt"); 
																try
																	{clientInfoDataFW = new FileWriter (clientInfoCheckingBal);
																	clientInfoDataBW = new BufferedWriter (clientInfoDataFW);
																	//clientInfoDataBW.newLine();
																	//clientInfoDataBW.write(createdUsername.getText());
																	clientInfoDataBW.write(strReadCheckingBalance[0]);
																	clientInfoDataBW.newLine();
																	clientInfoDataBW.close();}
																catch (IOException ioe) 
																	{
																	JOptionPane.showMessageDialog(bankMachineSim.this,
																								"Problem Writing to file. "+
																								"IOException: " + ioe.getMessage());
																	}
																
																clientInfoSavingsBal = new File ("clientInfoSavingsBalance.txt"); 
																try
																	{clientInfoDataFW = new FileWriter (clientInfoSavingsBal);
																	clientInfoDataBW = new BufferedWriter (clientInfoDataFW);
																	//clientInfoDataBW.newLine();
																	//clientInfoDataBW.write(createdUsername.getText());
																	clientInfoDataBW.write(strReadSavingsBalance[0]);
																	clientInfoDataBW.newLine();
																	clientInfoDataBW.close();}
																catch (IOException ioe) 
																	{
																	JOptionPane.showMessageDialog(bankMachineSim.this,
																								"Problem Writing to file. "+
																								"IOException: " + ioe.getMessage());
																	}
																transferSavingsDisplay.setVisible(false);
																tranSavingsNumPad.setVisible(false);
																tranEditKeys2.setVisible(false);
																getContentPane().add( reclogoutDisplayy2 );
																	}});
																	
		// -------------------------------------------------------------------------------------------------------
		//----------------------------------------- receipt transfer and logout listeners
		showBalanceT2.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ JOptionPane.showMessageDialog (bankMachineSim.this, "New Checking Balance: $"+strReadCheckingBalance[0]+"\nNew Savings Balance: $"+strReadSavingsBalance[0]);}});

		showlogoutT2.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){ JOptionPane.showMessageDialog (bankMachineSim.this, "Thank you for using virtual bank machine!"); System.exit( 0 ); }});
		
		
 		//Sets screen size and shows screen
    	setSize( 1000, 1000 );
    	this.setLocationRelativeTo(null);
    	//show();
		this.setVisible(true);
    }
    
    
/**
  * Checks if the client's password equal the password from database
  */
  private boolean isPasswordCorrect(char[] passwordInput) 
  {
  	//Assumes that the entry is correct
   	boolean isCorrect = true;
    //Sets the correct password
   	char[] correctPassword = strReadClientInfo[1].toCharArray();
		
	//If the length of the password is not equal to the length of the correct password, the entry
	//Is automatically incorrect
    if (passwordInput.length != correctPassword.length) 
  	{
       isCorrect = false;
	} 
	//If the entry passed the first condition, it matches the characters of the input and correct password
	//If they do not match, the entry is incorrect
	else 
	{
		 for (int i = 0; i < passwordInput.length; i++) 
		 {
			if (passwordInput[i] != correctPassword[i]) 
		    {
				isCorrect = false;
			}
		}
	}
						
						
		return isCorrect;
  }
  
    //Usual application main
    public static void main( String args[] )
    { 	
    	//Instantiates class
    	bankMachineSim app = new bankMachineSim();
		//Adds window listener
        app.addWindowListener(
        	new WindowAdapter() 
        	{
            	public void windowClosing( WindowEvent e )
            	{
               		System.exit( 0 );//Closes window
            	}
        	}
     	);
	} 
}